package apof.info.rss
{
	import mx.rpc.http.HTTPService;
	import mx.rpc.AsyncToken;
	import mx.rpc.Responder;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.events.FaultEvent;
	import mx.controls.Alert;
	import flash.events.EventDispatcher;
	import mx.rpc.Fault;
	import apof.info.event.RssEvent;
	import mx.managers.CursorManager;
	
	public class RssGetter extends EventDispatcher
	{
		private var _httpService:HTTPService;
		private var _rssXML:XML;
		
		public function doGet(url:String):void{
			CursorManager.setBusyCursor();
			_httpService = new HTTPService();
			
			//_httpService.
			_httpService.url = url;
			_httpService.contentType="application/xml";
			_httpService.useProxy = false;
			var atKen:AsyncToken=_httpService.send(null);
			atKen.addResponder(new Responder(OnResult,OnFault));
		}
		private function  OnResult(e:ResultEvent):void{
			CursorManager.removeBusyCursor();
			_rssXML = XML(e.message.body);
			this.dispatchEvent(new RssEvent(RssEvent.RssComplete));
		}
		
		private function  OnFault(e:FaultEvent):void{
			CursorManager.removeBusyCursor();
			Alert.show(e.fault.message);
		}
		
		//
		public function get rssXML():XML{
			return _rssXML;
		}
	}
}